/**
 * 
 */
package com.gragra.util;
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
import it.unimi.dsi.fastutil.longs.LongIterator;
/**
 * @author Christoph Teichmann
 * 14.10.2013
 */
public class PairNumberer
{
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString()
	{
		StringBuilder sb = new StringBuilder();
		sb.append("{");
		LongIterator li = numbers.keySet().iterator();
		while(li.hasNext())
		{
			sb.append(" <");
			long l = li.nextLong();
			sb.append(BooleanInterweave.getFirst(l));
			sb.append(",");
			sb.append(BooleanInterweave.getSecond(l));
			sb.append("> = ");
			sb.append(numbers.get(l));
		}
		sb.append(" }");
		return sb.toString();
	}
	/**
	 * 
	 */
	private Long2IntOpenHashMap numbers = new Long2IntOpenHashMap();
	/**
	 * 
	 * @param first
	 * @param second
	 * @param number
	 */
	public void put(int first, int second, int number)
	{numbers.put(BooleanInterweave.combine(first, second), number);}
	/**
	 * 
	 * @param first
	 * @param second
	 * @return
	 */
	public int get(int first, int second)
	{return numbers.get(BooleanInterweave.combine(first, second));}
}